<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>每日签到</title>
	<link rel="stylesheet" type="text/css" href="../css/normalize.css" />
	<link rel="stylesheet" type="text/css" href="../css/htmleaf-demo.css">
	<link rel="stylesheet" href="../css/style.css">
	<script src="../js/jquery-1.11.0.min.js"></script>
	<script src="../js/main.js"></script>
	<link rel="stylesheet" type="text/css" href="/mall/css/base.css"/>
	<link rel="stylesheet" type="text/css" href="/mall/css/index.css"/>
	<link rel="stylesheet" type="text/css" href="/mall/css/mui.min.css"/>
	<link rel="stylesheet" type="text/css" href="/mall/css/loaders.min.css"/>
	<link rel="stylesheet" type="text/css" href="/mall/css/loading.css"/>
	<link rel="stylesheet" href="/mall/css/swiper.min.css">
	<script src="/mall/js/jquery.min.js" type="text/javascript"></script>
	<script src="/js/plugins/jrender/jrender.min.js"></script>
	<script src="/mall/js/rem.js" type="text/javascript"></script>
	<script src="/mall/js/others.js" type="text/javascript"></script>
	<script src="/mall/js/swiper.jquery.min.js" type="text/javascript"></script>

	<meta name="viewport" content="width=device-width"/>

</head>
<body>

<div class="htmleaf-container" >
	<header class="mui-bar mui-bar-nav" id="header">
		<a href="/mine/profiles.html">
			<i class="iconfont icon-fanhui"></i>
		</a>
		<h4>签到</h4>
	</header><!--style="overflow:scroll"-->
	<!--<header class="htmleaf-header">-->
		<!--<meta name="viewport" content="width=device-width"/>-->
		<!--&lt;!&ndash;<h1>每日签到</h1>  <h1 id="seriesHtml"></h1>&ndash;&gt;-->
		<!--&lt;!&ndash;<div class="htmleaf-links">&ndash;&gt;-->

		<!--&lt;!&ndash;</div>&ndash;&gt;-->
	<!--</header>-->

	<!-- 我的签到 layer start -->
	<div class="qiandao-layer qiandao-history-layer">
		<div class="qiandao-layer-con qiandao-radius" >
			<a href="javascript:;" class="close-qiandao-layer qiandao-sprits"></a>
			<ul class="qiandao-history-inf clear">
				<li>
					<p>连续签到</p>
					<h4>5</h4>
				</li>
				<li>
					<p>本月签到</p>
					<h4>17</h4>
				</li>
				<li>
					<p>总共签到数</p>
					<h4>28</h4>
				</li>
				<li>
					<p>签到累计奖励</p>
					<h4>30</h4>
				</li>
			</ul>
			<div class="qiandao-history-table">
				<table>
					<thead>
					<tr>
						<th>签到日期</th>
						<th>奖励</th>
						<th>说明</th>
					</tr>
					</thead>
					<table>
						<tr>
							<td>2016-1-6 14:23:45</td>
							<td>0.20</td>
							<td>连续签到19天奖励</td>
						</tr>
						<tr>
							<td>2016-1-6 14:23:45</td>
							<td>0.20</td>
							<td>分享奖励</td>
						</tr>
						<tr>
							<td>2016-1-6 14:23:45</td>
							<td>0.20</td>
							<td>连续签到19天奖励</td>
						</tr>
						<tr>
							<td>2016-1-6 14:23:45</td>
							<td>0.20</td>
							<td>连续签到19天奖励</td>
						</tr>
						<tr>
							<td>2016-1-6 14:23:45</td>
							<td>0.20</td>
							<td>连续签到19天奖励</td>
						</tr>
						<tr>
							<td>2016-1-6 14:23:45</td>
							<td>0.20</td>
							<td>连续签到19天奖励</td>
						</tr>
						<tr>
							<td>2016-1-6 14:23:45</td>
							<td>0.20</td>
							<td>连续签到19天奖励</td>
						</tr>
						<tr>
							<td>2016-1-6 14:23:45</td>
							<td>0.20</td>
							<td>连续签到19天奖励</td>
						</tr>
					</table>
				</table>
			</div>
		</div>
		<div class="qiandao-layer-bg"></div>
	</div>
	<!-- 我的签到 layer end -->
	<!-- 签到 layer start -->
	<div class="qiandao-layer qiandao-active">
		<div class="qiandao-layer-con qiandao-radius">
			<a href="javascript:;" class="close-qiandao-layer qiandao-sprits"></a>
			<div class="yiqiandao clear">
				<div class="yiqiandao-icon qiandao-sprits" ></div>本月您已签到<span id="day"></span>天
			</div>
			<div class="qiandao-jiangli qiandao-sprits">
				<span class="qiandao-jiangli-num">50<em>积分</em></span>
			</div>
			<a href="#" class="qiandao-share qiandao-tran" id="share">分享到微博</a>
		</div>
		<div class="qiandao-layer-bg"></div>
	</div>
	<!-- 签到 layer end -->

	<div class="qiandao-warp">
		<div class="qiandap-box" style="width: 600px">
			<div class="qiandao-con clear" style="width:650px;height:670px">
				<div class="qiandao">
					<div class="qiandao-left-top clear">
						<div class="current-date"></div>
						<!--此功能没做故隐藏-->
						<div class="qiandao-history qiandao-tran qiandao-radius" id="js-qiandao-history" style="display: none">我的签到</div>
					</div>
					<div class="qiandao-main" id="js-qiandao-main" style="margin-left: 37px;margin-top: 15px">
						<ul class="qiandao-list" id="js-qiandao-list">
						</ul>
					</div>
				</div>

			</div>
		</div>
		<div class="qiandao" >

			<div >
				<div class="just-qiandao qiandao-sprits" id="js-just-qiandao" style="margin-right: 50px;margin-down: 50px">
				</div>
				<p class="qiandao-notic" style="margin-left: 50px;margin-down: 50px" id="seriesHtml"></p>
				<p class="qiandao-right" style="margin-left: 100px">签到每天获得50积分,连续签到26天及以上,每次签到额外获得300积分</p>
				<!--<p style="margin-left: 100px">连续签到26天及以上,每次签到额外获得300积分奖励</p>-->
			</div>
			<!--<div class="qiandao">-->
				<!--<div class="qiandao">-->
					<!--<h4>签到规则</h4>-->
					<!--<p>每天获得50积分奖励</p>-->
					<!--<p>连续签到25天及以上,每次签到额外获得300积分奖励</p>-->
				<!--</div>-->
				<!--<div class="qiandao-rule-list">-->
					<!--<h4>其他说明</h4>-->
					<!--<p>如果中间有一天间断未签到的，重先开始计算连续签到时间。</p>-->
					<!--<p>分享到微博后再次奖励50积分</p>-->

				<!--</div>-->
			<!--</div>-->
		</div>
	</div>

</div>
	
	<script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
	<script>window.jQuery || document.write('<script src="../js/jquery-1.11.0.min.js"><\/script>')</script>
	<script src="../js/main.js"></script>
	<script type="text/javascript">
		$(function(){

			//获得当前日期
			var date = new Date();
			var year = date.getFullYear();
			var month = date.getMonth()+1;
			var day = date.getDate();

			//状态
			var state = false;
            //拿出sessionStorage中存储的字符串json,并转为json对象
            var user = JSON.parse(sessionStorage.getItem("user"));
            //拿出用户的id
            var userId = user.id;
            //删除额外class
            $(".date"+2).removeClass('qiandao');
            $(".date"+3).removeClass('qiandao');
            $(".date"+5).removeClass('qiandao');
            $(".date"+7).removeClass('qiandao');
            //console.log(userId);
            
            //回显之前的登录数据
            $.get("/signIn/all",{userId:userId},function (data) {
                for(var i = 0;i<data.length;i++) {  //循环LIST
                    var veh = data[i];//获取LIST里面的对象
                    //console.log(data[i].dateId);

                    $(".date"+data[i].dateId).addClass('qiandao');

                }
            })
            
            $.get("/signIn",{userId:userId,dateId:day},function (data) {
                if(data){
                    $(".date"+day).addClass('qiandao');
                    state = true;
                    //激活已签到按钮
                    $("#js-just-qiandao").addClass("actived")

                }
            })

            //查出当前连续签到的天数
            $.get("/signIn/series",{userId:userId},function (data) {
                $("#seriesHtml").html("已连续签到"+data+"天")
                //console.log(data);
            })

            //求出签到天数
			$.get("/signIn/day",{userId:userId},function (data) {
				$("#day").html(data);
            })


			$(".current-date").text(year+"年"+month+"月"+day+"日");



			$("#js-just-qiandao").click(function () {
               //只增加一条签到记录
				if(state){
				    return;
				}
                $.post("/signIn/save",{userId:userId,dateId:day},function (data) {
					
                })
				//增加积分
				$.post("/point/dailyUpdate",{'user.id':userId},function (data) {

                })
				//查询连续签到
				$.get("/signIn/series",{userId:userId},function (data) {
                    if(data>25){
                        $.post("/point/seriesUpdate",{'user.id':userId},function (data) {

                        })
                    }
                })

               // $(".date"+day).addClass('qiandao');
                $.get("/signIn",{userId:userId,dateId:day},function (data) {
                    if(data){
                        $(".date"+day).addClass('qiandao');
                        state = true;
                        //激活已签到按钮
                        $("#js-just-qiandao").addClass("actived")

                    }
                })

            })




            	//分享到新浪微博
                var ShareTip = function(){}

                ShareTip.prototype.sharetosina=function(title,url)

                {

                    var sharesinastring='http://v.t.sina.com.cn/share/share.php?title='+title+'&url='+url+'&content=utf-8&sourceUrl='+url;

                    //            var sharesinastring='http://v.t.sina.com.cn/share/share.php?&appkey='+appkey+'&title='+title+'&url='+url+'&content=utf-8&sourceUrl='+url+'&pic='picurl;

                    window.open(sharesinastring,'newwindow','height=400,width=400,top=100,left=100');

                }



                $('#share').on('click', function () {
                    if(state){
                        alert('你已分享过了,明天再来')
                        return;
                    }
                    $.post("/point/dailyUpdate",{'user.id':userId},function (data) {

                    })
                    var shareTitle = "签到";

                    var shareContent = "快点来骡窝窝吧";

                    var shareUrl = window.location.href;

                    var share1 = new ShareTip();

                    share1.sharetosina(shareTitle + "  " + shareContent,shareUrl);

                })





		})
	</script>
</body>
</html>